#include "process_bar.h"
void ForTest()
{
    printf("this is a test\n");
    printf("this is a test\n");
    printf("this is a test\n");
    printf("this is a test\n");
    printf("this is a test\n");

}

const char* lable = "|/-\\";
//version 1
//void process_bar()
//{
//    char buff[length] = { 0 }; 
//    for (int i = 0; i < length; ++i)
//    {
//        printf("[%-100s][%d%%][%c]\r", buff, i, lable[i%4]);
//        fflush(stdout);
//        buff[i] = sign;
//        usleep(100000);
//    }
//    buff[length - 1] = '\0';
//    printf("\n");
//}
//Version2
void process_bar(double start, double total)
{
    char buff[length] = { 0 };
    int count = start * 100 / total;
    for (int i = 0; i < count; ++i)
    {
        buff[i] = sign;
    }
    buff[length - 1] = '\0';
    printf("[%-100s][%.1lf%%][%c]\r", buff, start, lable[count%4]);
    fflush(stdout);
}

